<?php
$host = "localhost"; // Host name 
$username = "root"; // Mysql username 
$password = "vertrigo"; // Mysql password 
$db_name = "tdc"; // Database name 
$tbl_name = "students"; // Table name 
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
mysql_query("set charset UTF8");
// select record from mysql 
$sql = "SELECT * FROM $tbl_name";
$result = mysql_query($sql);
	if( isset($_GET['edit']) )
	{
		$id= $_GET['edit'];
		$res= mysql_query("SELECT * FROM $tbl_name WHERE id='$id'");
		$row= mysql_fetch_array($res);
	}
 
	if(isset($_POST['newName']))
	{
		$newName = $_POST['newName'];
		$id  	 = $_POST['id'];
		$sql     = "UPDATE $tbl_name SET name='$newName' WHERE id='$id'";
		$res 	 = mysql_query($sql) or die("Could not update".mysql_error());
		
	}
?>
<form action="Index_update_Students.php" method="POST">
Name: <input type="text" name="newName" value="<?php echo $row[0];?>"/><br />
<input type="text" name="id" value="<?php echo $row[1];?>/>">
<input type="submit" value=" Update "/>
</form>